home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1997 / MacHack 1997.toast / Presentations / Presentations ’96 / Papers ’96 / Book of Practical Objects / BasicObjects ƒ / BasicObjectMain.cp < prev    next >
Encoding:
Text File  |  1996-04-29  |  1.1 KB  |  49 lines  |  [TEXT/CWIE]

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. #include "TreeNode.h"
  6. #include "BoyerMoore.h"
  7.  
  8.  
  9. // 10, 7, 5, 13, 6, 14, 12, 1
  10. void    main(void)
  11. {
  12.     TreeNode*    myTree = new TreeNode((void*)10, (void*) 0);
  13.     TreeNode*    outTree;
  14.     long        aNumber;
  15.  
  16.     myTree->InsertNode((void*) 7, (void*) 0);
  17.     myTree->InsertNode((void*) 5, (void*) 0);
  18.     myTree->InsertNode((void*) 13, (void*) 0);
  19.     myTree->InsertNode((void*) 6, (void*) 0);
  20.     myTree->InsertNode((void*) 14, (void*) 0);
  21.     myTree->InsertNode((void*) 12, (void*) 0);
  22.     myTree->InsertNode((void*) 1, (void*) 0);
  23.     
  24.     outTree = myTree->GetFirstNode();
  25.     do
  26.     {
  27.         aNumber = (long) outTree->GetNodeKey();
  28.         printf("%ld\n", aNumber);
  29.         outTree = outTree->GetNextNode();
  30.     }
  31.     while (outTree);
  32.     
  33.     
  34.     BoyerMoore    *bmSearch;
  35.     char*    testData = "a string searching example consisting of";
  36.     long    result;
  37.     
  38.     bmSearch = new BoyerMoore;
  39.     
  40.     bmSearch->SetSearchData(testData, strlen(testData));
  41.     result = bmSearch->Search(0, "\pstingy");
  42.     printf("Found search string at position %ld\n", result);
  43.  
  44.     result = bmSearch->Search(0, "\pof");
  45.     printf("Found search string at position %ld\n", result);
  46.  
  47. }
  48.  
  49.